package com.xianbeiying.app.ckgl.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.MyApplication;
import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.util.ToastUtil;

/**
 * 修改ip地址
 * */
public class ChangeIpActivity extends BaseActivity {
    private EditText et_user_name;
    private Button change_btn;
    private ImageView iv_title_left;
    private TextView tv_title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chnage_ip);
        init();
    }

    private void init() {
        et_user_name=(EditText) findViewById(R.id.et_user_name);
        et_user_name.setText(MyApplication.IP);
        change_btn=(Button) findViewById(R.id.change_btn);
        iv_title_left = (ImageView) findViewById(R.id.iv_title_left);
        tv_title = (TextView) findViewById(R.id.tv_title);
        change_btn.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                String strIp=et_user_name.getText().toString().trim();
                if(strIp.isEmpty()){
                    ToastUtil.showInfo(ChangeIpActivity.this,"请输入IP地址");
                    return;
                }
//                LogUtils.e("---",strIp);
//                MyApplication.IP=strIp;
//                SharedPreferencesUtils.setStringDate("ip",strIp);
                MyApplication.IP=strIp;
                finish();
            }
        });
        tv_title.setText("修改IP");
        iv_title_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
